import React, {Component} from 'react';
import './index.less';
import {base} from 'nc-lightapp-front';

const {NCModal, NCButton, NCTextArea} = base;
const {Header: NCModalHeader, Body: NCModalBody, Footer: NCModalFooter} = NCModal;

class RefuseModal extends Component {
    constructor(props) {
        super(props);
        this.state = {
            refuseReason: ''
        };
        this.initModal = this.initModal.bind(this);
        this.closeModal = this.closeModal.bind(this);
        this.beSure = this.beSure.bind(this);
    }

    initModal() {
        this.setState({
            refuseReason: ''
        })
    }

    beSure() {
        this.props.onSure(this.state.refuseReason);
        this.closeModal();
    }

    closeModal() {
        this.props.onClose();
    }

    render() {
        const {visible} = this.props;
        return (
            <NCModal
                show={visible}
                size="sm"
                onHide={this.closeModal}
                onEntered={this.initModal}
                backdrop={'static'}
            >
                <NCModalHeader
                    closeButton={true}
                >
                    {this.props.json['hi6007-000140']}{/* 国际化处理： 拒收处理*/}
                </NCModalHeader>
                <NCModalBody>
                    <div>{this.props.json['hi6007-000141']}</div>{/* 国际化处理： 填写拒收原因*/}
                    <NCTextArea
                        value={this.state.refuseReason}
                        onChange={(value) => this.setState({
                            refuseReason: value
                        })}
                    />
                </NCModalBody>
                <NCModalFooter>
                    <NCButton colors="primary" onClick={this.beSure}>
                        {this.props.json['hi6007-000174']}{/* 国际化处理： 确认*/}
                    </NCButton>
                    <NCButton shape="border" onClick={this.closeModal}>
                        {this.props.json['hi6007-000005']}{/* 国际化处理： 取消*/}
                    </NCButton>
                </NCModalFooter>
            </NCModal>
        );
    }
}

export default RefuseModal;
